<?php
use backend\assets\AppAsset;
use common\helpers\Html;
use common\helpers\Url;
AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="<?= Yii::$app->language ?>">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8" />
    <meta charset="<?= Yii::$app->charset ?>">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <!-- END THEME LAYOUT STYLES -->
    <link rel="shortcut icon" href="/favicon.ico" />
    <?php $this->head() ?>

</head>
<STYLE>
    .breadcrumb {
        padding: 11px 0px;
        margin-bottom: 0 ;
        background-color:#FFF;
        list-style: none;
        border-radius: 4px;
    }
</STYLE>
<!-- END HEAD -->

<body class="page-header-fixed page-sidebar-closed-hide-logo page-content-white">
<?php $this->beginBody() ?>
<!-- BEGIN HEADER -->
<?= $this->render(
    'header.php'
)
?>
<!-- END HEADER -->
<!-- BEGIN HEADER & CONTENT DIVIDER -->
<div class="clearfix"> </div>
<!-- END HEADER & CONTENT DIVIDER -->
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN SIDEBAR -->
    <?= $this->render('sidebar.php')?>
    <!-- END SIDEBAR -->
    <!-- BEGIN CONTENT -->
    <div class="page-content-wrapper" >
        <!-- BEGIN CONTENT BODY -->
        <div class="page-content" style="min-height: 1200px">
            <!-- BEGIN PAGE HEADER-->
            <!-- BEGIN PAGE BAR -->
            <div class="page-bar">
                <?= \yii\widgets\Breadcrumbs::widget(
                    [
                        'homeLink'=>false,
                        'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
                       // 'options' => ['class' => 'page-breadcrumb   ']
                    ]
                ) ?>
            </div>
            <!-- END PAGE BAR -->
            <!-- BEGIN PAGE TITLE-->
            <h3 class="page-title" >

            </h3>
            <!-- END PAGE TITLE-->
            <!-- END PAGE HEADER-->
            <!-- BEGIN DASHBOARD STATS 1-->
            <?= $content ?>
            <div class="clearfix"></div>
            <!-- END DASHBOARD STATS 1-->
        </div>
        <!-- END CONTENT BODY -->
    </div>
    <!-- END CONTENT -->
    <!-- END QUICK SIDEBAR -->
</div>
<!-- END CONTAINER -->
<!-- BEGIN FOOTER -->
<div class="page-footer">
    <div class="page-footer-inner"> 2016-2020 &copy;管理后台
    </div>
    <div class="scroll-to-top">
        <i class="icon-arrow-up"></i>
    </div>
</div>
<!-- END FOOTER -->




<!--ajax模拟框加载-->
<div class="modal fade" id="ajaxModal" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-body">
                <?= Html::img('@web/resources/img/loading.gif', ['class' => 'loading']) ?>
                <span>加载中... </span>
            </div>
        </div>
    </div>
</div>
<!--ajax大模拟框加载-->
<div class="modal fade" id="ajaxModalLg" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-body">
                <?= Html::img('@web/resources/img/loading.gif', ['class' => 'loading']) ?>
                <span>加载中... </span>
            </div>
        </div>
    </div>
</div>
<!--ajax最大模拟框加载-->
<div class="modal fade" id="ajaxModalMax" aria-hidden="true">
    <div class="modal-dialog modal-lg" style="width: 80%">
        <div class="modal-content">
            <div class="modal-body">
                <?= Html::img('@web/resources/img/loading.gif', ['class' => 'loading']) ?>
                <span>加载中... </span>
            </div>
        </div>
    </div>
</div>
<!--初始化模拟框-->
<div id="rfModalBody" class="hide">
    <div class="modal-body">
        <?= Html::img('@web/resources/img/loading.gif', ['class' => 'loading']) ?>
        <span>加载中... </span>
    </div>
</div>
<script>
    // 配置
    let config = {
        tag: false ,
        isMobile: false,
        emojiBaseUrl: "<?= Yii::$app->request->baseUrl ?>/resources/img/emoji/",
    };
</script>

<script>
    //rf.js
    function autoFontColor() {
        $("body").find("label").each(function (i, data) {
            if ($(data).find('input').length > 0) {
                $(data).attr('style', 'color:#636f7a');
            }
        })
    }



    // 小模拟框清除
    $('#ajaxModal').on('hide.bs.modal', function (e) {
        if (e.target == this) {
            $(this).removeData("bs.modal");
            $('#ajaxModal').find('.modal-content').html($('#rfModalBody').html());
        }
    });
    // 大模拟框清除
    $('#ajaxModalLg').on('hide.bs.modal', function (e) {
        if (e.target == this) {
            $(this).removeData("bs.modal");
            $('#ajaxModalLg').find('.modal-content').html($('#rfModalBody').html());
        }
    });
    // 最大模拟框清除
    $('#ajaxModalMax').on('hide.bs.modal', function (e) {
        if (e.target == this) {
            $(this).removeData("bs.modal");
            $('#ajaxModalMax').find('.modal-content').html($('#rfModalBody').html());
        }
    });

    // 小模拟框加载完成
    $('#ajaxModal').on('shown.bs.modal', function (e) {
        autoFontColor()
    });
    // 大模拟框加载完成
    $('#ajaxModalLg').on('shown.bs.modal', function (e) {
        autoFontColor()
    });
    // 最模拟框加载完成
    $('#ajaxModalMax').on('shown.bs.modal', function (e) {
        autoFontColor()
    });


    // 删除提示
    function rfDelete(obj, text) {
        if (!text) {
            text = '请谨慎操作';
        }

        bootbox.confirm({
            message: "您确定要删除这条记录吗?",
            buttons: {
                confirm: {
                    label: '确定',
                    className: 'btn-danger'
                },
                cancel: {
                    label: '放弃',
                    className: 'btn-success'
                }
            },
            callback: function (result) {
                switch (result) {
                    case true:
                        window.location = $(obj).attr('href');
                        break;
                    default:
                }
            }
        });

    }

    function rfAffirm(message , alertType) {
         alertType = alertType || 'warning';
        App.alert({
            container: $('#alert_container').val(), // alerts parent container
            place: 'append', // append or prepent in container
            type: alertType, // alert's type
            message: message, // alert's message
            close: true, // make alert closable
            reset: false, // close all previouse alerts first
            focus: true, // auto scroll to the alert after shown
        });
    }

    // 启用状态 status 1:启用;0禁用;
    function rfStatus(obj) {
        let id = $(obj).attr('data-id');
        let status = 0;
        self = $(obj);
        if (self.hasClass("btn-success")) {
            status = 1;
        }

        if (!id) {
            id = $(obj).parent().parent().attr('id');
        }

        if (!id) {
            id = $(obj).parent().parent().attr('data-key');
        }

        $.ajax({
            type: "get",
            url: "<?= Url::to(['ajax-update'])?>",
            dataType: "json",
            data: {
                id: id,
                status: status
            },
            success: function (data) {
                if (parseInt(data.code) === 200) {
                    if (self.hasClass("btn-success")) {
                        self.removeClass("btn-success").addClass("btn-default");
                        self.attr("data-toggle", 'tooltip');
                        self.attr("data-original-title", '点击禁用');
                        self.text('禁用');
                    } else {
                        self.removeClass("btn-default").addClass("btn-success");
                        self.attr("data-toggle", 'tooltip');
                        self.attr("data-original-title", '点击启用');
                        self.text('启用');
                    }
                } else {
                    rfAffirm(data.message);
                }
            }
        });
    }

    // 排序
    function rfSort(obj) {
        let id = $(obj).attr('data-id');

        if (!id) {
            id = $(obj).parent().parent().attr('id');
        }

        if (!id) {
            id = $(obj).parent().parent().attr('data-key');
        }

        var sort = $(obj).val();
        if (isNaN(sort)) {
            rfAffirm('排序只能为数字');
            return false;
        } else {
            $.ajax({
                type: "get",
                url: "<?=Url::to(['ajax-update'])?>",
                dataType: "json",
                data: {
                    id: id,
                    sort: sort
                },
                success: function (data) {
                    if (parseInt(data.code) !== 200) {
                        rfAffirm(data.message);
                    }
                }
            });
        }
    }
</script>





</body>

</html>
<?php $this->endBody() ?>
<?php $this->endPage() ?>
